<%--
  Created by IntelliJ IDEA.
  User: 李林
  Date: 2020/3/18
  Time: 21:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>ERP后台主页</title>
    <meta name="description" content="ERP后台主页">
    <meta name="keywords" content="ERP后台主页">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">

    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/ionicons/css/ionicons.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/iCheck/square/blue.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/morris/morris.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/datepicker/datepicker3.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/daterangepicker/daterangepicker.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/datatables/dataTables.bootstrap.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/treeTable/jquery.treetable.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/treeTable/jquery.treetable.theme.default.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/select2/select2.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/colorpicker/bootstrap-colorpicker.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/bootstrap-markdown/css/bootstrap-markdown.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/css/style.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/ionslider/ion.rangeSlider.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/ionslider/ion.rangeSlider.skinNice.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/bootstrap-slider/slider.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.css">
</head>

<body class="hold-transition skin-yellow-light sidebar-mini">

<div class="wrapper">

    <!-- 页面头部 -->
    <jsp:include page="../header.jsp"></jsp:include>
    <!-- 页面头部 /-->

    <!-- 导航侧栏 -->
    <jsp:include page="../aside.jsp"></jsp:include>
    <!-- 导航侧栏 /-->

    <!-- 内容区域 -->
    <div class="content-wrapper onjsp">
        <!-- ----------------------------------------------------------------------------- -->
        <section class="content-header">
            <h1>
                员工辞退中心
                <small>所有员工</small>
            </h1>
            <%--<input id="delinput1" type="search" class="breadcrumb"><button id="delbutton1" class="breadcrumb" type="button" onclick="searchuser()">查询</button>--%>
            <%--<br>--%>
            <%--<div class="input-group">--%>
                <%--<input type="text" id="delinput1" name="q" class="form-control" placeholder="搜索...">--%>
                <%--<span class="input-group-btn">--%>
                    <%--<button type="button" name="search" id="delbutton1" onclick="searchuser()" class="btn btn-flat"><i class="fa fa-search"></i>--%>
                        <%--</button>--%>
                <%--</span>--%>
            <%--</div>--%>
            <ol class="breadcrumb">
                <%--<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>--%>
                <%--<li><a href="#">Tables</a></li>--%>
                <%--<li class="active">Data tables</li>--%>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                            <%--<h2 class="box-title">员工列表</h2>--%>
                                <h2 class="" style="float: left;margin-top: 12px;">员工列表</h2>
                                <div style="width: 500px;float: right;">
                                    <form action="#" method="get" class="sidebar-form">
                                        <div class="input-group">
                                            <input type="text" id="delinput1" name="search_inp" class="form-control search_inp" placeholder="搜索...">
                                            <span class="input-group-btn">
                                            <button type="button" name="search" id="delbutton1" onclick="searchuser()"  class="btn btn-flat"><i class="fa fa-search"></i>
                                            </button>
                                          </span>
                                        </div>
                                    </form>
                                </div>
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body">
                            <table id="usertable" class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>UID</th>
                                    <th>用户名</th>
                                    <th>姓名</th>
                                    <th>邮箱</th>
                                    <th>电话</th>
                                    <th>性别</th>
                                    <th>入职日期</th>
                                    <th>权限</th>
                                    <th>操作</th>
                                </tr>
                                </thead>

                            </table>
                        </div>
                        <!-- /.box-body -->
                    </div>
                </div>
            </div>
        </section>
        <!-- ----------------------------------------------------------------------------- -->
    </div>
    <!-- 内容区域 /-->

    <!-- 底部导航 -->
    <jsp:include page="../foot.jsp"></jsp:include>
    <!-- 底部导航 /-->

</div>


<script src="${pageContext.request.contextPath}/pages/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/jQueryUI/jquery-ui.min.js"></script>
<script>
    $.widget.bridge('uibutton', $.ui.button);
</script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/raphael/raphael-min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/morris/morris.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/sparkline/jquery.sparkline.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/knob/jquery.knob.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/daterangepicker/moment.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/daterangepicker/daterangepicker.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/daterangepicker/daterangepicker.zh-CN.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/datepicker/bootstrap-datepicker.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/fastclick/fastclick.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/iCheck/icheck.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/adminLTE/js/app.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/treeTable/jquery.treetable.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/select2/select2.full.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.zh-CN.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-markdown/js/bootstrap-markdown.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-markdown/locale/bootstrap-markdown.zh.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-markdown/js/markdown.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-markdown/js/to-markdown.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/ckeditor/ckeditor.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/input-mask/jquery.inputmask.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/input-mask/jquery.inputmask.extensions.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/datatables/dataTables.bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/chartjs/Chart.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/flot/jquery.flot.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/flot/jquery.flot.resize.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/flot/jquery.flot.pie.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/flot/jquery.flot.categories.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/ionslider/ion.rangeSlider.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-slider/bootstrap-slider.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-datetimepicker/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/baiduTemplate/baiduTemplate.js"></script>
<script>
    $(document).ready(function() {
        // 选择框
        $(".select2").select2();

        // WYSIHTML5编辑器
        $(".textarea").wysihtml5({
            locale: 'zh-CN'
        });
    });

    // 设置激活菜单
    function setSidebarActive(tagUri) {
        var liObj = $("#" + tagUri);
        if (liObj.length > 0) {
            liObj.parent().parent().addClass("active");
            liObj.addClass("active");
        }
    }

    $(document).ready(function() {
        // 激活导航位置
        setSidebarActive("admin-index");
    });

    $(function() {
        $('#usertable').DataTable({
            "paging": true,
            "lengthChange": false,
            "searching": false,
            "ordering": false,
            "info": true,
            "autoWidth": false,
            ajax: function (data, callback, settings) {
                //封装请求参数
                var param = {};
                param.pageSize = data.length;//页面显示记录条数，在页面显示每页显示多少项的时候
                param.start = data.start;//开始的记录序号
                param.currentPage = (data.start / data.length) + 1;//当前页码
                //console.log(param);
                //ajax请求数据
                $.ajax({
                    type: "GET",
                    url: "usershow.do",
                    cache: false, //禁用缓存
                    data: param, //传入组装的参数
                    dataType: "json",
                    success: function (resultMap) {
                        var result = resultMap.resultList["result"];
                        var returnData = {};
                        returnData.draw = data.startRow;//这里直接自行返回了draw计数器,应该由后台返回
                        returnData.recordsTotal = result.total;//返回数据全部记录
                        returnData.recordsFiltered = result.total;//后台不实现过滤功能，每次查询均视作全部结果
                        returnData.data = result.list;//返回的数据列表
                        //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕
                        callback(returnData);
                    }
                });
            },
            "columns": [
                //跟你要显示的字段是一一对应的。我这里只显示八列
                {'data': 'uid'},
                {'data': 'username'},
                {'data': 'name'},
                {'data': 'email'},
                {'data': 'phoneNum'},
                {'data': 'genderStr'},
                {'data': 'date'},
                {'data': function (row, type, val, meta) {
                        var admin = row.roles[0].roleDesc;
                        return admin;}},
                {'data': function (row, type, val, meta) {
                        var a = '<a href="#" type="button" class="btn btn-sm btn-default" onclick="deleteuser('+row.uid+',\''+row.name+'\')"><i class="fa fa-edit"></i>辞退</a><br/>';
                        return a;}}
            ],
            language: {
                "sProcessing": "处理中...",
                "sLengthMenu": "显示 _MENU_ 项结果",
                "sZeroRecords": "没有匹配结果",
                "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                "sInfoPostFix": "",
                "sSearch": "搜索:",
                "sUrl": "",
                "sEmptyTable": "表中数据为空",
                "sLoadingRecords": "载入中...",
                "sInfoThousands": ",",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上页",
                    "sNext": "下页",
                    "sLast": "末页"
                },
                "oAria": {
                    "sSortAscending": ": 以升序排列此列",
                    "sSortDescending": ": 以降序排列此列"
                }
            }
        });
    });
</script>
<script id="user_td" type="text/template">
    <tr>
        <td><~=uid~></td>
        <td><~=username~></td>
        <td><~=name~></td>
        <td><~=email~></td>
        <td><~=phoneNum~></td>
        <td><~=genderStr~></td>
        <td><~=date~></td>
        <td><~=roles[0].roleDesc~></td>
        <td><a href="userdelete.do/<~=uid~>" type="button" class="btn btn-sm btn-default"><i class="fa fa-edit"></i>辞退</a></td>
    </tr>
</script>
<script id="user_tr" type="text/template">
    <thead>
    <tr>
        <th>UID</th>
        <th>用户名</th>
        <th>姓名</th>
        <th>邮箱</th>
        <th>电话</th>
        <th>性别</th>
        <th>入职日期</th>
        <th>权限</th>
        <th>操作</th>
    </tr>
    </thead>
</script>
</body>
</html>



<%--删除界面 输入员工编号 查询 删除--%>
<%--<input id="delinput" type="search"><button id="delbutton" type="button" onclick="searchuser()">查询</button>--%>
<%--<div id="list"></div>--%>
<script>
    function searchuser() {
        var name = $("#delinput1").val();
        // alert(name);
        $.post("usersearch",{"name":name},function (data) {
            var list = data.resultList["list"];
            if(list==null||list.length==0){
                $("#usertable").html("无数据");
                return;
            }
            var bt = baidu.template;
            $("#usertable").html($("#user_tr").html());
            for (var i = 0 ;i<list.length;i++){
                var html = bt("user_td",list[i]);
                $("#usertable").append(html);
            }
        })
    }

    function deleteuser(uid,uname) {
        if(confirm("你确定辞退"+uname+"吗？")==true){
            $.post("userdelete.do/"+uid,{},function (data) {
                alert(data.message);
                window.location.href="userdelete";
            })
        }
    }
</script>
